home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vidlibp
/
vidlib.bas
< prev
next >
Wrap
BASIC Source File
|
1995-05-08
|
12KB
|
375 lines
' Subsystem: Main
' Module: VidLib.Bas
' Date: 01/02/94
' Author: Richard Stauch
' Notes:
'
Option Explicit
DefInt A-Z
' Windows DLL functions.
' Get Windows directory.
Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
' Use Windows Help engine.
'Declare Function WinHelp Lib "User" (ByVal hwnd, ByVal lpzHelpFile, ByVal wCommand, ByVal dwData As Long)
Declare Function WinHelp Lib "User" (ByVal hwnd, ByVal HelpFile$, ByVal wCommand, ByVal dwData As Long)
' Commands to pass WinHelp(wCmd)
Global Const HELP_CONTEXT = &H1 ' Display topic identified by number in dwData
Global Const HELP_QUIT = &H2 ' Terminate help
Global Const HELP_INDEX = &H3 ' Display index
Global Const HELP_HELPONHELP = &H4 ' Display help on using help
' MousePointer
Global Const DEFAULT = 0 ' 0 - Default
Global Const HOURGLASS = 11 ' 11 - Hourglass
' MsgBox parameters.
' Buttons
Global Const MB_OK = 0 ' OK button only
Global Const MB_OKCANCEL = 1 ' OK and Cancel buttons
' Icons
Global Const MB_ICONSTOP = 16 ' Critical message
Global Const MB_ICONQUESTION = 32 ' Warning query
Global Const MB_ICONEXCLAMATION = 48 ' Warning message
Global Const MB_ICONINFORMATION = 64 ' Information message
' Return values
Global Const IDCANCEL = 2 ' Cancel button pressed
'Common Dialog Control
'Action Property
Global Const DLG_FILE_OPEN = 1
'File Open/Save Dialog Flags
Global Const OFN_SHOWHELP = &H10&
Global Const OFN_EXTENSIONDIFFERENT = &H400&
Global Const OFN_FILEMUSTEXIST = &H1000&
Global Const OFN_CREATEPROMPT = &H2000&
' Data control constants.
' Field Data Types
Global Const DB_INTEGER = 3
Global Const DB_LONG = 4
Global Const DB_TEXT = 10
Global Const DB_MEMO = 12
' CreateDatabase and CompactDatabase Language constants.
Global Const DB_LANG_GENERAL = ";LANGID=0x0809;CP=1252;COUNTRY=0"
' Validate event Action arguments
Global Const DATA_ACTIONCANCEL = 0
Global Const DATA_ACTIONMOVEFIRST = 1
Global Const DATA_ACTIONMOVEPREVIOUS = 2
Global Const DATA_ACTIONMOVENEXT = 3
Global Const DATA_ACTIONMOVELAST = 4
Global Const DATA_ACTIONUPDATE = 6
Global Const DATA_ACTIONFIND = 8
Global Const DATA_ACTIONCLOSE = 10
Global Const DATA_ACTIONUNLOAD = 11
' The version number of this program.
Global Const VERSION = "1.00"
' Show method parameter
Global Const MODAL = 1
' Check Value
Global Const UNCHECKED = 0 ' 0 - Unchecked
Global Const CHECKED = 1 ' 1 - Checked
Global Const GRAYED = 2 ' 2 - Grayed
' Application specific Constants.
' OK Message box procedure
Global Const MBC_BADDATA = 1
Global Const MBC_BADFILE = 2
Global Const MBC_CHECKFILE = 3
Global Const MBC_COPYPROBLEM = 4
Global Const MBC_CREATEPROBLEM = 5
Global Const MBC_NOBLANKS = 6
Global Const MBC_NOTABLES = 7
Global Const MBC_CODEINUSE = 8
' OK/Cancel message box procedure
Global Const MBC_REPLACEDATA = 1
Global Const MBC_REPAIRDATA = 2
' Global varibles.
' Data
Global Synopsis As String
' Control
Global CurrentRecordCode As String
Global Generic As String * 1
Global ReplaceData As Integer
Global GenreCopy As Integer
Global RatingCopy As Integer
Global VideoCopy As Integer
' Defaults
Global PathName As String
Global CopyName As String
Global TempName As String
Global HelpName As String
Global DefaultPath As String
Global DefaultName As String
Global DefaultReport As String
Global DefaultOutput As String
Global Const VIDLIB_MAIN = 1
Global Const VIDLIB_AUTHOR = 10
Global Const VIDLIB_SEARCH = 999
Function CheckFile (CheckStr As String) As Integer
' Check the existence of a file.
Dim X As String ' To hold return string from Dir$().
X$ = Dir$(CheckStr$)
' String length will zero if it doesn't exist.
If Len(X$) > 0 Then
' File exists.
CheckFile% = True
Else
' File does not exist.
CheckFile% = False
End If
End Function
Function CreateDataFile (FileStr As String) As Integer
' Create a new database file.
Dim DB As Database
' Create 3 new tables.
Dim T01 As New TableDef
Dim T02 As New TableDef
Dim T03 As New TableDef
' Create fields and indexes.
Dim F01 As New Field, F02 As New Field ' Video Code and Name.
Dim F03 As New Field, F04 As New Field ' Video Genre and Rating Codes.
Dim F05 As New Field, F06 As New Field ' Video Chroma and Recording Codes.
Dim F07 As New Field, F08 As New Field ' Video Release Year and Running Time Codes.
Dim F09 As New Field ' Video Synopsis (Memo).
Dim I01 As New Index, I02 As New Index ' Video Code and Name indexes.
Dim I03 As New Index, I04 As New Index ' Genre Code and Rating Code indexes.
Dim F10 As New Field, F11 As New Field ' Genre Code and Text.
Dim F12 As New Field, F13 As New Field ' Rating Code and Text.
Dim I05 As New Index, I06 As New Index ' Genre Code and Rating Code indexes.
On Error GoTo CreateError
Set DB = CreateDatabase(FileStr$, DB_LANG_GENERAL)
If DB Is Nothing Then GoTo CreateError
' Set up the table names.
T01.Name = "Video"
T02.Name = "Genre"
T03.Name = "Rating"
' Set up the fields for table 01 (Video).
F01.Name = "VidCode"
F01.Type = DB_TEXT: F01.Size = 20
T01.Fields.Append F01
F02.Name = "VidName"
F02.Type = DB_TEXT: F02.Size = 127
T01.Fields.Append F02
F03.Name = "GenCode"
F03.Type = DB_TEXT: F03.Size = 1
T01.Fields.Append F03
F04.Name = "RatCode"
F04.Type = DB_TEXT: F04.Size = 1
T01.Fields.Append F04
F05.Name = "RecCode"
F05.Type = DB_TEXT: F05.Size = 1
T01.Fields.Append F05
F06.Name = "CrmCode"
F06.Type = DB_TEXT: F06.Size = 1
T01.Fields.Append F06
F07.Name = "RlsYear"
F07.Type = DB_LONG
T01.Fields.Append F07
F08.Name = "RunTime"
F08.Type = DB_LONG
T01.Fields.Append F08
F09.Name = "SynText"
F09.Type = DB_MEMO
T01.Fields.Append F09
' Fields are complete. Now, set up the indexes.
I01.Name = "CdeIdx"
I01.Fields = "VidCode"
I01.Primary = False: I01.Unique = True
T01.Indexes.Append I01
I02.Name = "NamIdx"
I02.Fields = "VidName"
I02.Primary = True: I02.Unique = True
T01.Indexes.Append I02
I03.Name = "GenIdx"
I03.Fields = "GenCode"
I03.Primary = False: I03.Unique = False
T01.Indexes.Append I03
I04.Name = "RatIdx"
I04.Fields = "RatCode"
I04.Primary = False: I04.Unique = False
T01.Indexes.Append I04
' Table definition is complete. Add it to the Database Tabledefs object.
DB.TableDefs.Append T01
' Set up the Genre table.
F10.Name = "GenCode"
F10.Type = DB_TEXT
F10.Size = 1
T02.Fields.Append F10
F11.Name = "GenText"
F11.Type = DB_TEXT
F11.Size = 30
T02.Fields.Append F11
I05.Name = "GenIdx"
I05.Fields = "GenCode"
I05.Primary = True: I05.Unique = True
T02.Indexes.Append I05
DB.TableDefs.Append T02
' Set up the Rating table.
F12.Name = "RatCode"
F12.Type = DB_TEXT
F12.Size = 1
T03.Fields.Append F12
F13.Name = "RatText"
F13.Type = DB_TEXT
F13.Size = 30
T03.Fields.Append F13
I06.Name = "RatIdx"
I06.Fields = "RatCode"
I06.Primary = True: I06.Unique = True
T03.Indexes.Append I06
DB.TableDefs.Append T03
' Now, the new database is complete. Close it.
DB.Close
CreateDataFile% = True
Exit Function
CreateError:
GenericMsgBox (MBC_CREATEPROBLEM)
CreateDataFile% = False
Exit Function
End Function
Function GenericCancelBox (BoxToShow As Integer) As Integer
' Generic OK/Cancel Message Box.
Dim Msg As String ' Message to display.
Dim msgType As Integer ' Icon and buttons to use.
Dim msgTitle As String ' Title of the message box.
Dim response As Integer ' User response.
Select Case BoxToShow%
Case MBC_REPLACEDATA
' Replace data dialog.
msgTitle$ = "Replace Data"
msgType% = MB_OKCANCEL + MB_ICONQUESTION
Msg$ = "Are you sure you want to replace data?"
Case MBC_REPAIRDATA
' Repair database dialog.
msgTitle$ = "Repair Database"
msgType% = MB_OKCANCEL + MB_ICONINFORMATION
Msg$ = "Ready to repair database " + Pat